<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="app"></div>
    <button id="btn">按钮</button>
    <script>
        // const btn = document.querySelector('#btn')
        // btn.addEventListener('click',function(){
        //     document.querySelector('#app').innerHTML = '李旭'
        // })
        var name = '全局'
        let opener = {
            name: '李旭',
            addEvents: function (id) {
                // this
                document.querySelector(id).addEventListener('click', this.appendData.bind(this))
            },
            appendData: function () {
                document.querySelector('#app').innerHTML = this.name
            }
        }
        opener.addEvents('#btn')
    </script>
</body>

</html>